<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
        #allmap{width:100%;height:500px;}
        p{margin-left:5px; font-size:14px;}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=XPFOXZxZCZwuGqFninoYGjkPiXhPt5uu"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/CurveLine/1.5/src/CurveLine.min.js"></script>
    <title>添加椭圆</title>
</head>
<body>
<div id="allmap"></div>
<p>在地图上添加一个椭圆，圆的颜色为蓝色、线宽6px、透明度为1，填充颜色为白色，透明度为0.5</p>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 10);

    //centre:椭圆中心点,X:横向经度,Y:纵向纬度
    function add_oval(centre,x,y)
    {
        var assemble=new Array();
        var angle;
        var dot;
        var tangent=x/y;
        for(i=0;i<36;i++)
        {
            angle = (2* Math.PI / 36) * i;
            dot = new BMap.Point(centre.lng+Math.sin(angle)*y*tangent, centre.lat+Math.cos(angle)*y);
            assemble.push(dot);
        }
        return assemble;
    }
    var oval = new BMap.Polygon(add_oval(point,0.1,0.3), {strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5});
    map.addOverlay(oval);
</script>

